﻿using System;
using System.Diagnostics;
using Newtonsoft.Json;

namespace WinLiveHelper.Wp7
{
	[JsonObject(MemberSerialization=MemberSerialization.OptIn)]
	public class Event : Bindable
	{
		private string _id;
		[JsonProperty(PropertyName="id")]
		public string Id
		{
			[DebuggerStepThrough]
			get { return _id; }
			set
			{
				if (value != _id)
				{
					_id = value;
					OnPropertyChanged("Id");
				}
			}
		}

		private string _name;
		[JsonProperty(PropertyName = "name")]
		public string Name
		{
			[DebuggerStepThrough]
			get { return _name; }
			set
			{
				if (value != _name)
				{
					_name = value;
					OnPropertyChanged("Name");
				}
			}
		}

		private DateTime _createdTime;
		[JsonProperty(PropertyName = "created_time")]
		[JsonConverter(typeof(IsoDateTimeToUtcConverter))]
		public DateTime CreatedTime
		{
			[DebuggerStepThrough]
			get { return _createdTime; }
			set
			{
				if (value != _createdTime)
				{
					_createdTime = value;
					OnPropertyChanged("CreatedTime");
				}
			}
		}

		private DateTime _updatedTime;
		[JsonProperty(PropertyName = "updated_time")]
		[JsonConverter(typeof(IsoDateTimeToUtcConverter))]
		public DateTime UpdatedTime
		{
			[DebuggerStepThrough]
			get { return _updatedTime; }
			set
			{
				if (value != _updatedTime)
				{
					_updatedTime = value;
					OnPropertyChanged("UpdatedTime");
				}
			}
		}

		private string _description;
		[JsonProperty(PropertyName = "description")]
		public string Description
		{
			[DebuggerStepThrough]
			get { return _description; }
			set
			{
				if (value != _description)
				{
					_description = value;
					OnPropertyChanged("Description");
				}
			}
		}

		private string _calendarId;
		[JsonProperty(PropertyName = "calendar_id")]
		public string CalendarId
		{
			[DebuggerStepThrough]
			get { return _calendarId; }
			set
			{
				if (value != _calendarId)
				{
					_calendarId = value;
					OnPropertyChanged("CalendarId");
				}
			}
		}

		private From _from;
		[JsonProperty(PropertyName = "from")]
		public From From
		{
			[DebuggerStepThrough]
			get { return _from; }
			set
			{
				if (value != _from)
				{
					_from = value;
					OnPropertyChanged("From");
				}
			}
		}

		private DateTime _startTime;
		[JsonProperty(PropertyName = "start_time")]
		[JsonConverter(typeof(IsoDateTimeToUtcConverter))]
		public DateTime StartTime
		{
			[DebuggerStepThrough]
			get { return _startTime; }
			set
			{
				if (value != _startTime)
				{
					_startTime = value;
					OnPropertyChanged("StartTime");
				}
			}
		}

		private DateTime? _endTime;
		[JsonProperty(PropertyName = "end_time")]
		[JsonConverter(typeof(IsoDateTimeToUtcConverter))]
		public DateTime? EndTime
		{
			[DebuggerStepThrough]
			get { return _endTime; }
			set
			{
				if (value != _endTime)
				{
					_endTime = value;
					OnPropertyChanged("EndTime");
				}
			}
		}

		private string _location;
		[JsonProperty(PropertyName = "location")]
		public string Location
		{
			[DebuggerStepThrough]
			get { return _location; }
			set
			{
				if (value != _location)
				{
					_location = value;
					OnPropertyChanged("Location");
				}
			}
		}

		private bool _isAllDayEvent;
		[JsonProperty(PropertyName = "is_all_day_event")]
		public bool IsAllDayEvent
		{
			[DebuggerStepThrough]
			get { return _isAllDayEvent; }
			set
			{
				if (value != _isAllDayEvent)
				{
					_isAllDayEvent = value;
					OnPropertyChanged("IsAllDayEvent");
				}
			}
		}

		private bool _isRecurrent;
		[JsonProperty(PropertyName = "is_recurrent")]
		public bool IsRecurrent
		{
			[DebuggerStepThrough]
			get { return _isRecurrent; }
			set
			{
				if (value != _isRecurrent)
				{
					_isRecurrent = value;
					OnPropertyChanged("IsRecurrent");
				}
			}
		}

		private string _recurrence;
		[JsonProperty(PropertyName = "recurrence")]
		public string Recurrence
		{
			[DebuggerStepThrough]
			get { return _recurrence; }
			set
			{
				if (value != _recurrence)
				{
					_recurrence = value;
					OnPropertyChanged("Recurrence");
				}
			}
		}

		private int? _reminderTime;
		[JsonProperty(PropertyName = "reminder_time")]
		public int? ReminderTime
		{
			[DebuggerStepThrough]
			get { return _reminderTime; }
			set
			{
				if (value != _reminderTime)
				{
					_reminderTime = value;
					OnPropertyChanged("ReminderTime");
				}
			}
		}

		private string _availability;
		[JsonProperty(PropertyName = "availability")]
		public string Availability
		{
			[DebuggerStepThrough]
			get { return _availability; }
			set
			{
				if (value != _availability)
				{
					_availability = value;
					OnPropertyChanged("Availability");
				}
			}
		}
	}
}